﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Library;

namespace QLKH.PopUp.KhuyenMai
{
    public partial class popThemKM : Form
    {
        public popThemKM()
        {
            InitializeComponent();
        }

        public delegate void ThemKM(int outid);

        public ThemKM MyFuntion;

        private void popThemKM_Load(object sender, EventArgs e)
        {

        }

        private void btsave_Click(object sender, EventArgs e)
        {
            if (MyFuntion != null)
            {
                string tenKM = txtTenKM.Text.Trim();
                Int16 m3 = Int16.Parse((txtm3.Text.Trim() == "") ? "0" : txtm3.Text.Trim());
                string kieuKM = txtKieuKM.Text.Trim();
                Int16 hienthi = Int16.Parse((checkHienthi.Checked) ? "1" : "0");
                string tenkhongdau = Querys.LocDau(txtTenKM.Text.Trim()).ToLower();

                clKM adv = new clKM();
                int outid = adv.add(tenKM, m3, kieuKM, hienthi, tenkhongdau);
                MyFuntion(outid);
            }
            this.Close();
        }

        private void btquit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
